package com.zl.smartmall.library.po;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * 支付信息
 * @author 陈希然
 *
 */
public class PayInfo {

	private int payType;
	private String payName;

	public int getPayType() {
		return payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	public String getPayName() {
		return payName;
	}

	public void setPayName(String payName) {
		this.payName = payName;
	}
	
	public static PayInfo parse(JSONObject jsonObject) throws JSONException {
		PayInfo payInfo = null;
		if(jsonObject.length() > 0) {
			payInfo = new PayInfo();
			//用到的时候开启
			if(jsonObject.has("name"))
				payInfo.payName = jsonObject.getString("name");
			if(jsonObject.has("type"))
				payInfo.payType = jsonObject.getInt("type");
		}
		return payInfo;
	}
	
	public static List<PayInfo> parse(JSONArray jsonArray) throws JSONException {
		List<PayInfo> payInfos = new ArrayList<PayInfo>();
		for(int i = 0; jsonArray != null && i < jsonArray.length(); i++) {
			PayInfo payInfo = parse(jsonArray.getJSONObject(i));
			if(payInfo != null)
				payInfos.add(payInfo);
		}
		return payInfos;
	}
}
